﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using System.Drawing.Imaging;

public partial class image : System.Web.UI.Page
{
	private string cs = System.Configuration.ConfigurationManager.ConnectionStrings["Resist"].ConnectionString;

    protected void Page_Load(object sender, EventArgs e)
    {
		Response.Clear();
		int PostID = -1;
		try { PostID = int.Parse(Request.Url.AbsoluteUri.Substring(Request.Url.AbsoluteUri.LastIndexOf('?') + 1)); }
		catch { Response.End(); return; }
		DataRow dr = null;
		try { dr = KC.DataAccess.Global.Global.CallSql_Query(cs, "select image from Posts where ID="+PostID.ToString()).Rows[0]; }
		catch { Response.End(); return; }
		if (dr["Image"].GetType()==typeof(DBNull)) { Response.End(); return; }

		try {
			byte[] obj = (byte[])dr["Image"];
			if (obj.Length > 50) {
				System.Drawing.Image img = System.Drawing.Image.FromStream(new MemoryStream((byte[])obj));
				Response.ContentType = "image/jpeg";
				img.Save(Response.OutputStream, ImageFormat.Jpeg); }
		} catch { }
    }
}